<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>libwebsockets: Smtp</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="libwebsockets.org-logo.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">libwebsockets
   </div>
   <div id="projectbrief">Lightweight C library for HTML5 websockets</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li class="current"><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('group__smtp.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#enum-members">Enumerations</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">Smtp</div>  </div>
</div><!--header-->
<div class="contents">
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structlws__email.html">lws_email</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="enum-members"></a>
Enumerations</h2></td></tr>
<tr class="memitem:ga116be79bf44f9dc2a97f46e051fe4dc0"><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__smtp.html#ga116be79bf44f9dc2a97f46e051fe4dc0">lwsgs_smtp_states</a> { <br />
&#160;&#160;<a class="el" href="group__smtp.html#gga116be79bf44f9dc2a97f46e051fe4dc0a29e5b0ecf75375b5a643faa3d6222b7c">LGSSMTP_IDLE</a>, 
<a class="el" href="group__smtp.html#gga116be79bf44f9dc2a97f46e051fe4dc0ab89442b7a3ca2b94c3cdcf33756eb933">LGSSMTP_CONNECTING</a>, 
<a class="el" href="group__smtp.html#gga116be79bf44f9dc2a97f46e051fe4dc0ab61778f70ecac007b334bb14942eb41d">LGSSMTP_CONNECTED</a>, 
<a class="el" href="group__smtp.html#gga116be79bf44f9dc2a97f46e051fe4dc0a1dfec948a864205cec875f63cbe0d4ad">LGSSMTP_SENT_HELO</a>, 
<br />
&#160;&#160;<a class="el" href="group__smtp.html#gga116be79bf44f9dc2a97f46e051fe4dc0a929bb4623ff3f585108aba2a1b047fab">LGSSMTP_SENT_FROM</a>, 
<a class="el" href="group__smtp.html#gga116be79bf44f9dc2a97f46e051fe4dc0aae20a0cb95b97a70f6b45d0ed2d5be83">LGSSMTP_SENT_TO</a>, 
<a class="el" href="group__smtp.html#gga116be79bf44f9dc2a97f46e051fe4dc0a85e3c452950c09a79086bff4b9be5c14">LGSSMTP_SENT_DATA</a>, 
<a class="el" href="group__smtp.html#gga116be79bf44f9dc2a97f46e051fe4dc0a38fba41f28d754e38079b31418a86a69">LGSSMTP_SENT_BODY</a>, 
<br />
&#160;&#160;<a class="el" href="group__smtp.html#gga116be79bf44f9dc2a97f46e051fe4dc0a2c2ed16ffc572326e3040684084b21d5">LGSSMTP_SENT_QUIT</a>
<br />
 }</td></tr>
<tr class="separator:ga116be79bf44f9dc2a97f46e051fe4dc0"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga77fc9b56a1bb39484844981ec375fc29"><td class="memItemLeft" align="right" valign="top">LWS_VISIBLE LWS_EXTERN int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__smtp.html#ga77fc9b56a1bb39484844981ec375fc29">lws_email_init</a> (struct <a class="el" href="structlws__email.html">lws_email</a> *email, uv_loop_t *loop, int max_content)</td></tr>
<tr class="separator:ga77fc9b56a1bb39484844981ec375fc29"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga5e535e346d92a9daf00be33abf79d4eb"><td class="memItemLeft" align="right" valign="top">LWS_VISIBLE LWS_EXTERN void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__smtp.html#ga5e535e346d92a9daf00be33abf79d4eb">lws_email_check</a> (struct <a class="el" href="structlws__email.html">lws_email</a> *email)</td></tr>
<tr class="separator:ga5e535e346d92a9daf00be33abf79d4eb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga25298a5afc1074e13b2d5711a86432b2"><td class="memItemLeft" align="right" valign="top">LWS_VISIBLE LWS_EXTERN void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__smtp.html#ga25298a5afc1074e13b2d5711a86432b2">lws_email_destroy</a> (struct <a class="el" href="structlws__email.html">lws_email</a> *email)</td></tr>
<tr class="separator:ga25298a5afc1074e13b2d5711a86432b2"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<h2>SMTP related functions</h2>
<p>These apis let you communicate with a local SMTP server to send email from lws. It handles all the SMTP sequencing and protocol actions.</p>
<p>Your system should have postfix, sendmail or another MTA listening on port 25 and able to send email using the "mail" commandline app. Usually distro MTAs are configured for this by default.</p>
<p>It runs via its own libuv events if initialized (which requires giving it a libuv loop to attach to).</p>
<p>It operates using three callbacks, on_next() queries if there is a new email to send, on_get_body() asks for the body of the email, and on_sent() is called after the email is successfully sent.</p>
<p>To use it</p>
<ul>
<li>create an <a class="el" href="structlws__email.html">lws_email</a> struct</li>
<li>initialize data, loop, the email_* strings, max_content_size and the callbacks</li>
<li>call <a class="el" href="group__smtp.html#ga77fc9b56a1bb39484844981ec375fc29">lws_email_init()</a></li>
</ul>
<p>When you have at least one email to send, call <a class="el" href="group__smtp.html#ga5e535e346d92a9daf00be33abf79d4eb">lws_email_check()</a> to schedule starting to send it. </p>
<h2 class="groupheader">Enumeration Type Documentation</h2>
<a class="anchor" id="ga116be79bf44f9dc2a97f46e051fe4dc0"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">enum <a class="el" href="group__smtp.html#ga116be79bf44f9dc2a97f46e051fe4dc0">lwsgs_smtp_states</a></td>
        </tr>
      </table>
</div><div class="memdoc">

<p><code>#include &lt;<a class="el" href="libwebsockets_8h.html">lib/libwebsockets.h</a>&gt;</code></p>
<p>enum lwsgs_smtp_states - where we are in SMTP protocol sequence </p>
<table class="fieldtable">
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><a class="anchor" id="gga116be79bf44f9dc2a97f46e051fe4dc0a29e5b0ecf75375b5a643faa3d6222b7c"></a>LGSSMTP_IDLE&#160;</td><td class="fielddoc">
<p>awaiting new email </p>
</td></tr>
<tr><td class="fieldname"><a class="anchor" id="gga116be79bf44f9dc2a97f46e051fe4dc0ab89442b7a3ca2b94c3cdcf33756eb933"></a>LGSSMTP_CONNECTING&#160;</td><td class="fielddoc">
<p>opening tcp connection to MTA </p>
</td></tr>
<tr><td class="fieldname"><a class="anchor" id="gga116be79bf44f9dc2a97f46e051fe4dc0ab61778f70ecac007b334bb14942eb41d"></a>LGSSMTP_CONNECTED&#160;</td><td class="fielddoc">
<p>tcp connection to MTA is connected </p>
</td></tr>
<tr><td class="fieldname"><a class="anchor" id="gga116be79bf44f9dc2a97f46e051fe4dc0a1dfec948a864205cec875f63cbe0d4ad"></a>LGSSMTP_SENT_HELO&#160;</td><td class="fielddoc">
<p>sent the HELO </p>
</td></tr>
<tr><td class="fieldname"><a class="anchor" id="gga116be79bf44f9dc2a97f46e051fe4dc0a929bb4623ff3f585108aba2a1b047fab"></a>LGSSMTP_SENT_FROM&#160;</td><td class="fielddoc">
<p>sent FROM </p>
</td></tr>
<tr><td class="fieldname"><a class="anchor" id="gga116be79bf44f9dc2a97f46e051fe4dc0aae20a0cb95b97a70f6b45d0ed2d5be83"></a>LGSSMTP_SENT_TO&#160;</td><td class="fielddoc">
<p>sent TO </p>
</td></tr>
<tr><td class="fieldname"><a class="anchor" id="gga116be79bf44f9dc2a97f46e051fe4dc0a85e3c452950c09a79086bff4b9be5c14"></a>LGSSMTP_SENT_DATA&#160;</td><td class="fielddoc">
<p>sent DATA request </p>
</td></tr>
<tr><td class="fieldname"><a class="anchor" id="gga116be79bf44f9dc2a97f46e051fe4dc0a38fba41f28d754e38079b31418a86a69"></a>LGSSMTP_SENT_BODY&#160;</td><td class="fielddoc">
<p>sent the email body </p>
</td></tr>
<tr><td class="fieldname"><a class="anchor" id="gga116be79bf44f9dc2a97f46e051fe4dc0a2c2ed16ffc572326e3040684084b21d5"></a>LGSSMTP_SENT_QUIT&#160;</td><td class="fielddoc">
<p>sent the session quit </p>
</td></tr>
</table>
<div class="fragment"><div class="line"><a name="l04128"></a><span class="lineno"> 4128</span>&#160;                       {</div><div class="line"><a name="l04129"></a><span class="lineno"> 4129</span>&#160;        <a class="code" href="group__smtp.html#gga116be79bf44f9dc2a97f46e051fe4dc0a29e5b0ecf75375b5a643faa3d6222b7c">LGSSMTP_IDLE</a>, </div><div class="line"><a name="l04130"></a><span class="lineno"> 4130</span>&#160;        <a class="code" href="group__smtp.html#gga116be79bf44f9dc2a97f46e051fe4dc0ab89442b7a3ca2b94c3cdcf33756eb933">LGSSMTP_CONNECTING</a>, </div><div class="line"><a name="l04131"></a><span class="lineno"> 4131</span>&#160;        <a class="code" href="group__smtp.html#gga116be79bf44f9dc2a97f46e051fe4dc0ab61778f70ecac007b334bb14942eb41d">LGSSMTP_CONNECTED</a>, </div><div class="line"><a name="l04132"></a><span class="lineno"> 4132</span>&#160;        <a class="code" href="group__smtp.html#gga116be79bf44f9dc2a97f46e051fe4dc0a1dfec948a864205cec875f63cbe0d4ad">LGSSMTP_SENT_HELO</a>, </div><div class="line"><a name="l04133"></a><span class="lineno"> 4133</span>&#160;        <a class="code" href="group__smtp.html#gga116be79bf44f9dc2a97f46e051fe4dc0a929bb4623ff3f585108aba2a1b047fab">LGSSMTP_SENT_FROM</a>, </div><div class="line"><a name="l04134"></a><span class="lineno"> 4134</span>&#160;        <a class="code" href="group__smtp.html#gga116be79bf44f9dc2a97f46e051fe4dc0aae20a0cb95b97a70f6b45d0ed2d5be83">LGSSMTP_SENT_TO</a>, </div><div class="line"><a name="l04135"></a><span class="lineno"> 4135</span>&#160;        <a class="code" href="group__smtp.html#gga116be79bf44f9dc2a97f46e051fe4dc0a85e3c452950c09a79086bff4b9be5c14">LGSSMTP_SENT_DATA</a>, </div><div class="line"><a name="l04136"></a><span class="lineno"> 4136</span>&#160;        <a class="code" href="group__smtp.html#gga116be79bf44f9dc2a97f46e051fe4dc0a38fba41f28d754e38079b31418a86a69">LGSSMTP_SENT_BODY</a>, </div><div class="line"><a name="l04137"></a><span class="lineno"> 4137</span>&#160;        <a class="code" href="group__smtp.html#gga116be79bf44f9dc2a97f46e051fe4dc0a2c2ed16ffc572326e3040684084b21d5">LGSSMTP_SENT_QUIT</a>, </div><div class="line"><a name="l04138"></a><span class="lineno"> 4138</span>&#160;};</div><div class="ttc" id="group__smtp_html_gga116be79bf44f9dc2a97f46e051fe4dc0ab61778f70ecac007b334bb14942eb41d"><div class="ttname"><a href="group__smtp.html#gga116be79bf44f9dc2a97f46e051fe4dc0ab61778f70ecac007b334bb14942eb41d">LGSSMTP_CONNECTED</a></div><div class="ttdef"><b>Definition:</b> libwebsockets.h:4131</div></div>
<div class="ttc" id="group__smtp_html_gga116be79bf44f9dc2a97f46e051fe4dc0a38fba41f28d754e38079b31418a86a69"><div class="ttname"><a href="group__smtp.html#gga116be79bf44f9dc2a97f46e051fe4dc0a38fba41f28d754e38079b31418a86a69">LGSSMTP_SENT_BODY</a></div><div class="ttdef"><b>Definition:</b> libwebsockets.h:4136</div></div>
<div class="ttc" id="group__smtp_html_gga116be79bf44f9dc2a97f46e051fe4dc0a29e5b0ecf75375b5a643faa3d6222b7c"><div class="ttname"><a href="group__smtp.html#gga116be79bf44f9dc2a97f46e051fe4dc0a29e5b0ecf75375b5a643faa3d6222b7c">LGSSMTP_IDLE</a></div><div class="ttdef"><b>Definition:</b> libwebsockets.h:4129</div></div>
<div class="ttc" id="group__smtp_html_gga116be79bf44f9dc2a97f46e051fe4dc0ab89442b7a3ca2b94c3cdcf33756eb933"><div class="ttname"><a href="group__smtp.html#gga116be79bf44f9dc2a97f46e051fe4dc0ab89442b7a3ca2b94c3cdcf33756eb933">LGSSMTP_CONNECTING</a></div><div class="ttdef"><b>Definition:</b> libwebsockets.h:4130</div></div>
<div class="ttc" id="group__smtp_html_gga116be79bf44f9dc2a97f46e051fe4dc0aae20a0cb95b97a70f6b45d0ed2d5be83"><div class="ttname"><a href="group__smtp.html#gga116be79bf44f9dc2a97f46e051fe4dc0aae20a0cb95b97a70f6b45d0ed2d5be83">LGSSMTP_SENT_TO</a></div><div class="ttdef"><b>Definition:</b> libwebsockets.h:4134</div></div>
<div class="ttc" id="group__smtp_html_gga116be79bf44f9dc2a97f46e051fe4dc0a929bb4623ff3f585108aba2a1b047fab"><div class="ttname"><a href="group__smtp.html#gga116be79bf44f9dc2a97f46e051fe4dc0a929bb4623ff3f585108aba2a1b047fab">LGSSMTP_SENT_FROM</a></div><div class="ttdef"><b>Definition:</b> libwebsockets.h:4133</div></div>
<div class="ttc" id="group__smtp_html_gga116be79bf44f9dc2a97f46e051fe4dc0a2c2ed16ffc572326e3040684084b21d5"><div class="ttname"><a href="group__smtp.html#gga116be79bf44f9dc2a97f46e051fe4dc0a2c2ed16ffc572326e3040684084b21d5">LGSSMTP_SENT_QUIT</a></div><div class="ttdef"><b>Definition:</b> libwebsockets.h:4137</div></div>
<div class="ttc" id="group__smtp_html_gga116be79bf44f9dc2a97f46e051fe4dc0a1dfec948a864205cec875f63cbe0d4ad"><div class="ttname"><a href="group__smtp.html#gga116be79bf44f9dc2a97f46e051fe4dc0a1dfec948a864205cec875f63cbe0d4ad">LGSSMTP_SENT_HELO</a></div><div class="ttdef"><b>Definition:</b> libwebsockets.h:4132</div></div>
<div class="ttc" id="group__smtp_html_gga116be79bf44f9dc2a97f46e051fe4dc0a85e3c452950c09a79086bff4b9be5c14"><div class="ttname"><a href="group__smtp.html#gga116be79bf44f9dc2a97f46e051fe4dc0a85e3c452950c09a79086bff4b9be5c14">LGSSMTP_SENT_DATA</a></div><div class="ttdef"><b>Definition:</b> libwebsockets.h:4135</div></div>
</div><!-- fragment -->
</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="ga5e535e346d92a9daf00be33abf79d4eb"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">LWS_VISIBLE LWS_EXTERN void lws_email_check </td>
          <td>(</td>
          <td class="paramtype">struct <a class="el" href="structlws__email.html">lws_email</a> *&#160;</td>
          <td class="paramname"><em>email</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p><code>#include &lt;<a class="el" href="libwebsockets_8h.html">lib/libwebsockets.h</a>&gt;</code></p>
<p><a class="el" href="group__smtp.html#ga5e535e346d92a9daf00be33abf79d4eb">lws_email_check()</a> - Request check for new email</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">email</td><td>struct <a class="el" href="structlws__email.html">lws_email</a> context to check</td></tr>
  </table>
  </dd>
</dl>
<p>Schedules a check for new emails in 1s... call this when you have queued an email for send. </p>

</div>
</div>
<a class="anchor" id="ga25298a5afc1074e13b2d5711a86432b2"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">LWS_VISIBLE LWS_EXTERN void lws_email_destroy </td>
          <td>(</td>
          <td class="paramtype">struct <a class="el" href="structlws__email.html">lws_email</a> *&#160;</td>
          <td class="paramname"><em>email</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p><code>#include &lt;<a class="el" href="libwebsockets_8h.html">lib/libwebsockets.h</a>&gt;</code></p>
<p><a class="el" href="group__smtp.html#ga25298a5afc1074e13b2d5711a86432b2">lws_email_destroy()</a> - stop using the struct <a class="el" href="structlws__email.html">lws_email</a></p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">email</td><td>the struct <a class="el" href="structlws__email.html">lws_email</a> context</td></tr>
  </table>
  </dd>
</dl>
<p>Stop sending email using email and free allocations </p>

</div>
</div>
<a class="anchor" id="ga77fc9b56a1bb39484844981ec375fc29"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">LWS_VISIBLE LWS_EXTERN int lws_email_init </td>
          <td>(</td>
          <td class="paramtype">struct <a class="el" href="structlws__email.html">lws_email</a> *&#160;</td>
          <td class="paramname"><em>email</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uv_loop_t *&#160;</td>
          <td class="paramname"><em>loop</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>max_content</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p><code>#include &lt;<a class="el" href="libwebsockets_8h.html">lib/libwebsockets.h</a>&gt;</code></p>
<p><a class="el" href="group__smtp.html#ga77fc9b56a1bb39484844981ec375fc29">lws_email_init()</a> - Initialize a struct <a class="el" href="structlws__email.html">lws_email</a></p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">email</td><td>struct <a class="el" href="structlws__email.html">lws_email</a> to init </td></tr>
    <tr><td class="paramname">loop</td><td>libuv loop to use </td></tr>
    <tr><td class="paramname">max_content</td><td>max email content size</td></tr>
  </table>
  </dd>
</dl>
<p>Prepares a struct <a class="el" href="structlws__email.html">lws_email</a> for use ending SMTP </p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.11 </li>
  </ul>
</div>
</body>
</html>
